//
//  RegisterViewController.m
//  02_拉勾的3个界面
//
//  Created by dllo on 16/7/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "RegisterViewController.h"
#import "AccountView.h"

@interface RegisterViewController ()
@property (nonatomic, strong) AccountView *phoneNumberView;
@property (nonatomic, strong) AccountView *securityCodeView;
@end

@implementation RegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIImageView *welcomeImageView = [[UIImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    welcomeImageView.image = [UIImage imageNamed:@"welcome_2"];
    [self.view addSubview:welcomeImageView];
    
    UIImageView *lagouImageView = [[UIImageView alloc] initWithFrame:CGRectMake(147, 93, 120, 185)];
    lagouImageView.image = [UIImage imageNamed:@"logo_lagou"];
    [self.view addSubview:lagouImageView];
    
    self.phoneNumberView = [[AccountView alloc] initWithFrame:CGRectMake(20, 331, 374, 55) image:[UIImage imageNamed:@"phone"]];
    UIBezierPath *phoneNumberMaskPath = [UIBezierPath bezierPathWithRoundedRect:self.phoneNumberView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(5, 5)];
    CAShapeLayer *phoneNumberMaskLayer = [[CAShapeLayer alloc] init];
    phoneNumberMaskLayer.frame = self.phoneNumberView.bounds;
    phoneNumberMaskLayer.path = phoneNumberMaskPath.CGPath;
    self.phoneNumberView.layer.mask = phoneNumberMaskLayer;
    self.phoneNumberView.textField.placeholder = @"请输入手机号";
    [self.phoneNumberView.textField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
    [self.view addSubview:self.phoneNumberView];
    
    self.securityCodeView = [[AccountView alloc] initWithFrame:CGRectMake(20, 388, 374, 55) image:[UIImage imageNamed:@"securityCode"]];
    UIBezierPath *securityCodeMaskPath = [UIBezierPath bezierPathWithRoundedRect:self.phoneNumberView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(5, 5)];
    CAShapeLayer *securityCodeMaskLayer = [[CAShapeLayer alloc] init];
    securityCodeMaskLayer.frame = self.securityCodeView.bounds;
    securityCodeMaskLayer.path = securityCodeMaskPath.CGPath;
    self.securityCodeView.layer.mask = securityCodeMaskLayer;
    self.securityCodeView.textField.placeholder = @"请输入验证码";
    [self.securityCodeView.textField setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
    
    UIButton *securityCodeButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [securityCodeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
    [securityCodeButton setTitleColor:[UIColor colorWithRed:38 / 255.0f green:103 / 255.0f blue:80 / 255.0f alpha:1] forState:UIControlStateNormal];
    securityCodeButton.titleLabel.textColor = [UIColor colorWithRed:43 / 255.0f green:118 / 255.0f blue:87 / 255.0f alpha:1];
    securityCodeButton.frame = CGRectMake(8, 0, 105, 55);
    self.securityCodeView.textField.rightView.backgroundColor = [UIColor redColor];
    self.securityCodeView.textField.rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 121, 55)];
    self.securityCodeView.textField.rightViewMode = UITextFieldViewModeAlways;
    [self.securityCodeView.textField.rightView addSubview: securityCodeButton];
    UIView *securityCodeLineView = [[UIView alloc] initWithFrame:CGRectMake(0, 15, 1, 24)];
    securityCodeLineView.backgroundColor = [UIColor grayColor];
    [self.securityCodeView.textField.rightView addSubview: securityCodeLineView];
    [self.view addSubview:self.securityCodeView];
    
    UIImageView *registerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(60, 450, 22, 24)];
    [registerImageView setImage:[UIImage imageNamed:@"icon_chat_resume_send"]];
    [self.view addSubview:registerImageView];
    
    UILabel *registerInfoLabel = [[UILabel alloc] initWithFrame:CGRectMake(84, 450, 248, 24)];
    NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:@"注册代表你已同意拉勾用户协议"];
    NSDictionary *attributeDictFormer = @{NSForegroundColorAttributeName: [UIColor grayColor]};
    NSDictionary *attributeDictLast = @{NSForegroundColorAttributeName: [UIColor colorWithRed:50 / 255.0f green:138 / 255.0f blue:105 / 255.0f alpha:1]};
    [attributedStr setAttributes:attributeDictFormer range:NSMakeRange(0, 8)];
    [attributedStr setAttributes:attributeDictLast range:NSMakeRange(8, 6)];
    registerInfoLabel.attributedText = attributedStr;    
    [self.view addSubview:registerInfoLabel];
    
    UIButton *returnLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    returnLoginButton.backgroundColor = [UIColor clearColor];
    returnLoginButton.layer.cornerRadius = 5;
    returnLoginButton.layer.borderColor = [UIColor colorWithRed:49 / 255.0f green:134 / 255.0f blue:101 / 255.0f alpha:1].CGColor;
    returnLoginButton.layer.borderWidth = 1;
    [returnLoginButton setTitle:@"返回登录" forState:UIControlStateNormal];
    [returnLoginButton setTitleColor:[UIColor colorWithRed:0 green:161 / 255.0f blue:123 / 255.0f alpha:1] forState:UIControlStateNormal];
    returnLoginButton.frame = CGRectMake(20, 591, 374, 50);
    [returnLoginButton addTarget:self action:@selector(returnLoginAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:returnLoginButton];
    
    UIButton *registerButton = [UIButton buttonWithType:UIButtonTypeCustom];
    registerButton.backgroundColor = [UIColor colorWithRed:59 / 255.0f green:165 / 255.0f blue:117 / 255.0f alpha:1];
    [registerButton setTitle:@"注册" forState:UIControlStateNormal];
    [registerButton setTitleColor:[UIColor colorWithRed:69 / 255.0f green:188 / 255.0f blue:150 / 255.0f alpha:1] forState:UIControlStateNormal];
    registerButton.frame = CGRectMake(20, 519, 374, 50);
    registerButton.layer.cornerRadius = 5;
    [self.view addSubview:registerButton];
    
    
}

- (void)returnLoginAction {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
